<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类式组件</title>
    <style>
        header{
            height: 100px;
            background: #aef;
        }
        section{
            height: 400px;
            background: #efa;
        }
        footer{
            height: 100px;
            background: #fae;
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <script type="text/babel">
        //1. 类式组件   声明一个类  Component 中 C 是大写的
        class Toubu extends React.Component{
            //方法名是固定的, 必须写成 小写的 render , 单词含义: 渲染
            render(){
                //返回虚拟 DOM 对象
                return <header>头部xxx</header>;
            }
        }

        //一定要细心
        class Neirong extends React.Component{
            render(){
                return <section>内容xx</section>;
            }
        }

        class Dibu extends React.Component{
            render(){
                return <footer>底部abc</footer>;
            }
        }

        class App extends React.Component{
            render(){
                return <div>
                    {/*内部会自动寻找这个类, 然后实例化对象, 并调用 render 方法, 得到虚拟DOM对象*/}
                    <Toubu></Toubu>
                    <Neirong />         
                    <Dibu />
                </div>;
            }
        }
        
        ReactDOM.render(<App />, document.querySelector("#root"));
    </script>
</body>
</html>